package com.whfc.emp.service.impl;

import com.whfc.emp.dao.ReportReceiverMapper;
import com.whfc.emp.entity.ReportReceiver;
import com.whfc.emp.service.ReportReceiverService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 日报接收记录Service实现类
 */
@Service
public class ReportReceiverServiceImpl implements ReportReceiverService {

    @Resource
    private ReportReceiverMapper reportReceiverMapper;

    @Override
    public int addReceiver(ReportReceiver receiver) {
        return reportReceiverMapper.insert(receiver);
    }

    @Override
    public int addReceiverSelective(ReportReceiver receiver) {
        return reportReceiverMapper.insertSelective(receiver);
    }

    @Override
    public ReportReceiver getById(Long id) {
        return reportReceiverMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ReportReceiver> getByReportId(Long reportId) {
        return reportReceiverMapper.selectByReportId(reportId);
    }

    @Override
    public List<ReportReceiver> getByReceiver(Long receiverId, Integer readStatus) {
        Map<String,Object> map = new HashMap<>();
        map.put("receiverId",receiverId);
        map.put("readStatus",readStatus);
        return reportReceiverMapper.selectByReceiver(map);
    }

    @Override
    public int updateReadStatus(Long reportId, Long receiverId, Integer readStatus) {
        return reportReceiverMapper.updateReadStatus(reportId, receiverId, readStatus);
    }

    @Override
    public int updateReceiver(ReportReceiver receiver) {
        return reportReceiverMapper.updateByPrimaryKey(receiver);
    }

    @Override
    public int updateReceiverSelective(ReportReceiver receiver) {
        return reportReceiverMapper.updateByPrimaryKeySelective(receiver);
    }

    @Override
    public int deleteById(Long id) {
        return reportReceiverMapper.deleteByPrimaryKey(id);
    }
}